# -*- coding: utf-8 -*-
# @Time    : 2021/10/22 5:11 下午
# @Author  : CHENlj
# @File    : Func.py

from Common import Public, ApiAdress
from Common.Request import Request
import json


def refresh_token():
    """
    刷新token
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetToken)
    data = Public.create_default_data(ApiAdress.GetToken)
    return Request.post_request(ApiAdress.GetToken, headers=headers, data=data), data


def get_index_data():
    """
    获取首页数据
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetIndexData)
    data = Public.create_default_data(ApiAdress.GetIndexData)
    return Request.post_request(ApiAdress.GetIndexData, headers=headers, data=data), data


def get_sign_every_day():
    """
    获取日历签到信息
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetSignEveryData)
    data = Public.create_default_data(ApiAdress.GetSignEveryData)
    return Request.post_request(ApiAdress.GetSignEveryData, headers=headers, data=data), data


def do_sign_every_day_top():
    """
    每日签到弹窗操作
    :return:
    """
    headers = Public.create_headers(ApiAdress.DoSignEveryDayPop)
    data = Public.create_default_data(ApiAdress.DoSignEveryDayPop)
    return Request.post_request(ApiAdress.DoSignEveryDayPop, headers=headers, data=data), data


def everyday_sign_pop_remind():
    """
    打开日历签到提醒获取奖励
    :return:
    """
    headers = Public.create_headers(ApiAdress.EveryDaySignPopRemind)
    data = Public.create_default_data(ApiAdress.EveryDaySignPopRemind)
    return Request.post_request(ApiAdress.EveryDaySignPopRemind, headers=headers, data=data), data


def set_val(key, val):
    """
    保存引导
    :param key:
    :param val:
    :return:
    """
    headers = Public.create_headers(ApiAdress.SetVal)
    data = {
        "val": val,
        "key": key
    }
    data = json.dumps(data)
    return Request.post_request(ApiAdress.SetVal, headers=headers, data=data), data


def get_sign_every_pop_reward():
    """
    签到弹窗，再领一次奖励
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetSignEveryPopReward)
    data = Public.create_default_data(ApiAdress.GetSignEveryPopReward)
    return Request.post_request(ApiAdress.GetSignEveryPopReward, headers=headers, data=data), data


def open_box():
    """
    开宝箱
    :return:
    """
    headers = Public.create_headers(ApiAdress.OpenBox)
    data = Public.create_default_data(ApiAdress.OpenBox)
    return Request.post_request(ApiAdress.OpenBox, headers=headers, data=data), data


def get_coin_task_reward(task_id):
    """
    请求完成金币任务的奖励
    :param task_id:
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetCoinTaskReward)
    data = {
        "TaskId": task_id
    }
    data = json.dumps(data)
    return Request.post_request(ApiAdress.GetCoinTaskReward, headers=headers, data=data), data


def get_coin_task_index():
    """
    打开金币任务首页
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetCoinTaskIndex)
    data = Public.create_default_data(ApiAdress.GetCoinTaskIndex)
    return Request.get_request(ApiAdress.GetCoinTaskIndex, data, headers), data


def get_coin_task_list():
    """
    获取金币任务列表
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetCoinTaskList)
    data = {
        "status": Public.AuditStatus
    }
    data = json.dumps(data)
    return Request.get_request(ApiAdress.GetCoinTaskList, data, headers), data


def get_today_coin():
    """
    今日获得金币总数
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetTodayCoin)
    data = Public.create_default_data(ApiAdress.GetTodayCoin)
    return Request.get_request(ApiAdress.GetTodayCoin, data, headers), data


def get_reward_sign_pop_reward():
    """
    签到拆红包，查看广告奖励金币数
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetRewardSignPopReward)
    data = Public.create_default_data(ApiAdress.GetRewardSignPopReward)
    return Request.get_request(ApiAdress.GetRewardSignPopReward, data, headers), data


def do_coin_task(task_id):
    """
    做金币任务接口
    :return:
    """
    headers = Public.create_headers(ApiAdress.DoCoinTask)
    data = {
        "TaskId": task_id
    }
    data = json.dumps(data)
    return Request.post_request(ApiAdress.DoCoinTask, data=data, headers=headers), data


def get_reward_sign_data():
    """
    获取今日拆红包签到情况
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetRewardSignData)
    data = Public.create_default_data(ApiAdress.GetRewardSignData)
    return Request.get_request(ApiAdress.GetRewardSignData, data, headers), data


def do_reward_sign():
    """
    拆红包签到操作
    :return:
    """
    headers = Public.create_headers(ApiAdress.DoRewardSign)
    data = Public.create_default_data(ApiAdress.DoRewardSign)
    return Request.get_request(ApiAdress.DoRewardSign, data, headers), data


def get_reward_sign_pop_data():
    """
    获取今日拆红包签到弹窗情况
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetRewardSignPopData)
    data = Public.create_default_data(ApiAdress.GetRewardSignPopData)
    return Request.get_request(ApiAdress.GetRewardSignPopData, data, headers), data


def do_reward_sign_pop():
    """
    拆红包签到弹窗操作
    :return:
    """
    headers = Public.create_headers(ApiAdress.DoRewardSignPop)
    data = Public.create_default_data(ApiAdress.DoRewardSignPop)
    return Request.post_request(ApiAdress.DoRewardSignPop, data, headers=headers), data


def reward_sign_pop_remind():
    """
    添加拆红包签到弹窗日历提醒
    :return:
    """
    headers = Public.create_headers(ApiAdress.RewardSignPopRemind)
    data = Public.create_default_data(ApiAdress.RewardSignPopRemind)
    return Request.get_request(ApiAdress.RewardSignPopRemind, data, headers), data


def get_back_data():
    """
    获取后退广告的红包数据
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetBackData)
    data = Public.create_default_data(ApiAdress.GetBackData)
    return Request.get_request(ApiAdress.GetBackData, data, headers), data


def receive_back_data(red_packet_id):
    """
    拆后退广告的红包
    :return:
    """
    headers = Public.create_headers(ApiAdress.ReceiveBackData)
    data = {
        "Id": red_packet_id
    }
    data = json.dumps(data)
    return Request.post_request(ApiAdress.ReceiveBackData, data, headers=headers), data


def receive_new_user_cash():
    """
    领取新人现金红包
    :return:
    """
    headers = Public.create_headers(ApiAdress.ReceiveNewUserCash)
    data = Public.create_default_data(ApiAdress.ReceiveNewUserCash)
    return Request.get_request(ApiAdress.ReceiveNewUserCash, data, headers), data


def get_lucky_bag():
    """
    获取福袋列表数据
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetLuckyBag)
    data = Public.create_default_data(ApiAdress.GetLuckyBag)
    return Request.get_request(ApiAdress.GetLuckyBag, data, headers), data


def open_lucky_bag(task_id):
    """
    开福袋
    :return:
    """
    headers = Public.create_headers(ApiAdress.OpenLuckyBag)
    data = {
        "TaskId": task_id
    }
    data = json.dumps(data)
    return Request.post_request(ApiAdress.OpenLuckyBag, data, headers=headers), data


def get_profit_index():
    """
    打开我的收益首页
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetProfitIndex)
    data = Public.create_default_data(ApiAdress.GetProfitIndex)
    return Request.get_request(ApiAdress.GetProfitIndex, data, headers), data


def get_coin_profit(page, limit):
    """
    获取金币收益记录
    :param page: 第几页
    :param limit: 每页多少
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetCoinProfit)
    data = {
        "Page": page,
        "Limit": limit
    }
    data = json.dumps(data)
    return Request.post_request(ApiAdress.GetCoinProfit, data, headers=headers), data


def get_money_profit(page, limit):
    """
    获取现金收益记录
    :param page:
    :param limit:
    :return:
    """
    headers = Public.create_headers(ApiAdress.GetMoneyProfit)
    data = {
        "Page": page,
        "Limit": limit
    }
    data = json.dumps(data)
    return Request.post_request(ApiAdress.GetMoneyProfit, data, headers=headers), data


if __name__ == '__main__':
    res, d = get_money_profit(1,10)
    print('data: ', d)
    print('res1:', res.text)

    print('res_data:', res.json())

